<?php
$param = $_POST['myparam'];
$count = 5;
switch ($param) {
    case 1 : $count = 7;
        break;
    case 2 : $count = 6;
        break;
    case 1 : $count = 8;
        break;
    default : $count = 5;
        break;
}
?>
<div id="menu"> 
    <div id="centre"></div>
    <ul>
        <?php
        for ($i = 1; $i <= $count; $i++) {
            echo '<li id="item' . $i . '" value="' . $i . '"><img src="image.jpg" width="40" height="40"/></li>';
        }
        ?>
    </ul>
</div>
<div id="result"> 
    <div id="centre2"></div>
    <ul>
        <?php
        for ($i = 1; $i <= $count; $i++) {
            echo '<li id="result' . $i . '" value="' . $i . '"></li>';
        }
        ?>
    </ul>
</div>